import os
import glob

def sortedList():

    list = glob.glob(os.environ['PWD']+'/archives/*/*/*')

    di = {}

    for item in list:
        try:
            if os.path.isdir(item):
                numComments = len(os.listdir(item+'/comments/'))
                di[numComments].append(item)
        except :
            di[numComments]=[]
            di[numComments].append(item)
    keys = di.items()

    keys.sort(reverse=True)

    return keys


def sortDict(adict):
    keys = adict.keys()
    keys.sort()
    return [adict[key] for key in keys]
